package com.xyhua.houseproperty.controller;

import com.xyhua.houseproperty.dao.UserMapper;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

import lombok.extern.slf4j.Slf4j;

/**
 * description: TestController <br>
 * date: 2020/3/28 3:06 下午 <br>
 * author: huaxiansheng <br>
 * version: 1.0 <br>
 */

@Controller
@Slf4j
public class TestController {

    @Resource
    UserMapper mUserMapper;

    @GetMapping("t1")
    @ResponseBody
    public String get1() {
        return mUserMapper.getUserById("7").getName();
    }

    @GetMapping(value = "t2")
    @Valid
    public String get2(@NotBlank(message = "name不能为空") String  name, ModelMap modelMap) {
        modelMap.put("name", name);
        return "index";
    }

    @GetMapping(value = "t3")
    @ResponseBody
    public String t3() {
        log.info("info1111111111111111111111111111111111111111111111111111111111111111111");
        log.warn("warnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarn");
        log.debug("debugwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarn");
        log.error("errorwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarn");
        log.trace("tracewarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarnwarn");
        return String.valueOf(111);
    }
}
